package com.heima.utils.common;

import com.heima.model.wemedia.pojos.WmUser;

//创建一个泛型WmUser的线程局部对象 工具类
public class WmThreadLocalUtil {
        //定义ThreadLocal对象
      private final static ThreadLocal<WmUser> WM_USER_THREAD_LOCAL = new ThreadLocal<>();

      //添加用户数据到ThreadLocal
        public static void setUser(WmUser wmUser){
            WM_USER_THREAD_LOCAL.set(wmUser);
        }

        //从ThreadLocal获取用户
        public static WmUser getUser(){
            return WM_USER_THREAD_LOCAL.get();
        }

        //清理用户
        public static void remove(){
           WM_USER_THREAD_LOCAL.remove();
        }

}
